#include "StdAfx.h"
#include "CircuitSimProbe.h"

CCircuitSimProbe::CCircuitSimProbe(void)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
	m_szName = _T("");
}

CCircuitSimProbe::CCircuitSimProbe(const CCircuitSimProbe *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX = pEntityObj->GetPosX();
	m_dblPosY = pEntityObj->GetPosY();
	m_dblColor[0] = pEntityObj->GetColorR();
	m_dblColor[1] = pEntityObj->GetColorG();
	m_dblColor[2] = pEntityObj->GetColorB();
	m_bSelected = pEntityObj->GetSelect();
	m_szName = pEntityObj->GetName();
}

CCircuitSimProbe::CCircuitSimProbe(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
	m_szName = _T("");
}

CCircuitSimProbe::~CCircuitSimProbe(void)
{
	Clear();
}

void CCircuitSimProbe::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblColor[0];
		ar << m_dblColor[1];
		ar << m_dblColor[2];
		ar << m_bSelected;
		CObj::WriteString(ar, m_szName);
	}
	else
	{
		ar >> m_dblPosX;
		ar >> m_dblPosY;
		ar >> m_dblColor[0];
		ar >> m_dblColor[1];
		ar >> m_dblColor[2];
		ar >> m_bSelected;
		CObj::ReadString(ar, m_szName);
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitSimProbe::Clone() const
{
	return new CCircuitSimProbe(this);
}

void CCircuitSimProbe::Transform(const CMatrix transf)
{

}

bool CCircuitSimProbe::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitSimProbe::Clear()
{

}

void CCircuitSimProbe::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitSimProbe::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitSimProbe::CreateDisplayObj(long lLayerId)
{
	CCircuitSimProbeDisObj *pProbeDis = new CCircuitSimProbeDisObj(this);
	pProbeDis->SetLayerId(lLayerId);
	return pProbeDis;
}

void CCircuitSimProbe::CalcBox()
{
	m_minX = m_dblPosX;
	m_minY = m_dblPosY;
	m_maxX = m_dblPosX+10;
	m_maxY = m_dblPosY+10;
}

eCircuitUnitEntType CCircuitSimProbe::GetUnitType() const
{
	return CIRCUIT_PROBE;
}

double CCircuitSimProbe::GetPosX() const
{
	return m_dblPosX;
}

double CCircuitSimProbe::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitSimProbe::GetColorR() const
{
	return m_dblColor[0];
}

double CCircuitSimProbe::GetColorG() const
{
	return m_dblColor[1];
}

double CCircuitSimProbe::GetColorB() const
{
	return m_dblColor[2];
}

bool CCircuitSimProbe::GetSelect() const
{
	return  m_bSelected;
}

void CCircuitSimProbe::SetPosX( double dblPosX)
{
	m_dblPosX = dblPosX;
}

void CCircuitSimProbe::SetPosY( double dblPosY)
{
	m_dblPosY = dblPosY;
}

void CCircuitSimProbe::SetColorR( double colR)
{
	m_dblColor[0] = colR;
}

void CCircuitSimProbe::SetColorG( double colG)
{
	m_dblColor[1] = colG;
}

void CCircuitSimProbe::SetColorB( double colB)
{
	m_dblColor[2] = colB;
}

void CCircuitSimProbe::SetSelect( bool bSelected)
{
	m_bSelected = bSelected;
}


CString CCircuitSimProbe::GetName() const
{
	return m_szName;
}

void CCircuitSimProbe::SetName( CString szName)
{
	m_szName = szName;
}
